1. Technical Field
The present disclosure relates generally to a communication apparatus and method based on shared memory and, more particularly, to a communication apparatus and method based on shared memory, which control access to shared memory among pluralities of data publishers and data subscribers.
2. Description of the Related Art
In general, when pluralities of data subscribers and data publishers send and receive data through shared memory, a publisher activates a locking function while the publisher is performing writing on the shared memory, and thus prevents another publisher or subscriber from accessing the shared memory. When the locking function is deactivated, a subscriber may fetch the changed data from the shared memory. The subscriber also activates a function of locking the shared memory in order to indicate that the changed data has been read.
However, this conventional method is problematic in that, if a data subscriber or a data publisher who has used the shared memory in the process of locking the shared memory and then changing data is subjected to termination without performing unlocking due to an internal error or other problems, another data subscriber or another data publisher cannot access the shared memory.
For this purpose, a method has been proposed in which a standby data subscriber or a standby data publisher performs forced unlocking if a data subscriber or a data publisher who occupies shared memory is subjected to termination. However, in this case, unlocking operations may be simultaneously performed in the state in which pluralities of data publishers and data subscribers are simultaneously on standby. Accordingly, when a single data publisher or a single data subscriber locks shared memory again after performing forced unlocking and then performs a task, another data publisher or another data subscriber may mistake the locking of the shared memory, performed by the data publisher or the data subscriber who performed the forced unlocking, as the locking of the shared memory that had performed by a data publisher or a data subscriber who had been subjected to termination, and may then perform forced unlocking again. As a result, this method is problematic in that pluralities of data publishers and data subscribers may simultaneously access the shared memory because the pluralities of data publishers and data subscribers successively release the locking states of each other.
As related technology, Korean Patent Application Publication No. 10-2012-0067865 discloses a method and apparatus for shared memory channel multiplexing.